[
	
	//this can be slow in big sites with multi level navbar turned on, so we cache it in the sessions
	
	//if( !(Lasso_TagExists: 'navbar'));
			Define_Tag: 
				'navbar',
				-optional='Group',
				-optional='xtraReturn',
				-optional='depth',
				-optional='relative',
				-optional='table',
				-optional='id',
				-optional='xtraWhere',
				-priority='replace'
				;
					!(var_defined('this_navbarOut')) ? var('this_navbarOut' = string);
					$this_navbarOut = string; //uncommenting this will force the navbar to re-create itself on each pageview

					if($this_navbarOut->size == 0);
				
						// if these params are not is not submitted we submit defaults
						!local('id')->size ? local('id' = 1);  
						!local('table')->size ? local('table' = 'Pages');
						!local('depth')->size ? local('depth' = 1);
						!local('relative')->size ? local('id' = true);
						!local('xtraWhere')->size ? local('xtraWhere' = '');
						!local('xtraReturn')->size ? local('xtraReturn' = ', node.navorder, node.page_url') | local('xtraReturn' = ', node.navorder, node.page_url, ' + #xtraReturn); // for this one, we ALWAYS wnat these, but they're not built into jono's tag, so we tack them on here
						!local('group')->size ? local('Group' = 1);
						
						var('get1' = (
							xs_cat->(
								subTreeSQL(
									-id=#id, 
									-cattable=#table,
									-depth=#depth,
									-relative=#relative,
									-xtraReturn=#xtraReturn,
									-xtraWhere=#xtraWhere + ' AND node.visible_in_menu = ' #Group''
									
									)))
							);
						inline($connection_db, -sql=($get1));
								$this_navbarOut += '<ul class="nav" id="navgroup-'#Group'">';
								rows;
										var('name' = column('name'));
										var('url' = column('page_url'));
										var('nodeID' = column('id'));
										
										var('path_to_node' = (xs_cat->getURLpath(-id=$nodeID, -cattable=#Table)));
										
										(!$show_home_in_navbar) && ($path_to_node == '/') ? loop_continue;
										
										
										$this_navbarOut += '<li  class="'(response_path>>$path_to_node ? ' current')'">';
										
										// link
										$this_navbarOut += '<a ' (response_path>>$path_to_node ? ' class="on"') ' href="'+$path_to_node+'">';
										$this_navbarOut += $name;
										
										$this_navbarOut += '</a>';
										
										
												var('get1' = (xs_cat->(subTreeSQL(-id=$nodeID, -cattable='Pages',-depth=1,-relative=true,-xtraReturn=', node.navorder, node.page_url',-xtraWhere=' AND node.visible_in_menu = 1'))));
												if($multi_level_navbar);
														inline($connection_db, -sql=($get1));
														
																$debug ? $admin_content += '<h3>navbar, in multi level:</h3><code><pre>'$get1 '</pre></code>';
																
																
																if(found_count > 1);
																		$this_navbarOut += '<ul>';
																		
																		rows;
																		
																				column('depth') == 0 ? loop_continue;
																				var('name' = column('name'));
																				var('nodeid'=column('id'));
																				var('path_to_node' = (xs_cat->getURLpath(-id=column('id'), -cattable='Pages')));
																				!$path_to_node->beginswith('/') ? $path_to_node = '/' + $path_to_node;
																				$this_navbarOut += '<li class="'(response_path>>$path_to_node ? ' current')' '(loop_count == found_count ? 'last ')'">';
																				
																				
																				
																						$this_navbarOut += '<a href="'+$path_to_node+'" '(response_path>>$path_to_node ? ' class="on"') ' >';
																						
																								$this_navbarOut += $name;
																						
																						$this_navbarOut += '</a>';
																						
																				
																				$this_navbarOut += '</li>';
																		/rows;
																		$this_navbarOut +=  '</ul>';
																/if;
														/inline;
												/if;
										$this_navbarOut += '</li>';
								/rows;
								
								$this_navbarOut += '</ul>';
						/inline;
						
						return(@$this_navbarOut);
					
					else;
						return(@$this_navbarOut);
					/if;
					
					
			/define_tag;
			
	///if;
	
]

